<template>
  <div class="OKRDistributionDetails">
    <div class="OKRDistributionDetails-title">部门分布详情</div>
    <div
      class="OKRDistributionDetails-echarts"
      v-for="(item, index) in data"
      :key="index"
    >
      <div class="OKRDistributionDetails-echarts-title">{{ item.bm_name }}</div>
      <div class="OKRDistributionDetails-echarts-data">
        <div :id="'postponenumB' + index"></div>
        <div :id="'postponenumZ' + index"></div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
import { postHomeObjectiveDetail_rating } from "@/api";

import { postponenumZF, postponenumBF } from "./postponenum.js";
export default {
  data() {
    return {
      data: [],
      form: {
        okr_effective_cycle: "",
      },
    };
  },
  async mounted() {
    this.form.okr_effective_cycle = this.$route.query.okr_effective_cycle;
    await this.postHomeObjectiveDetail_rating(this.form);
    // this.postponenumBF(postponenumBF(this.detailThree.fb.list));
    // this.postponenumZF(postponenumZF(this.detailThree.fb.list));
  },
  methods: {
    async postHomeObjectiveDetail_rating() {
      let res = await postHomeObjectiveDetail_rating(this.form);
      console.log("res", res);
      let datas = res.data.info;
      this.data = datas;
      setTimeout(() => {
        for (let index = 0; index < datas.length; index++) {
        this.postponenumZF(postponenumZF(datas[index].list), index);
        this.postponenumBF(postponenumBF(datas[index].list), index);
      }
      }, 1000);
      
    },
    async postponenumZF(data, index) {
      let id = "postponenumZ" + index;
      console.log("id", id);
      let myChart = echarts.init(document.getElementById(id));
      // 绘制图表
      myChart.setOption(data);
    },
    async postponenumBF(data,index) {
      let id = "postponenumB" + index;
      console.log("id", id);
      let myChart = echarts.init(document.getElementById(id));
      // 绘制图表
      myChart.setOption(data);
    },
  },
};
</script>

<style lang="scss" scoped>

.OKRDistributionDetails {
  .OKRDistributionDetails-title {
    font-size: 18px;
    font-weight: 800;
    margin-top: 20px;
  }
  .OKRDistributionDetails-echarts {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    .OKRDistributionDetails-echarts-title {
      font-weight: 800;
    }
    .OKRDistributionDetails-echarts-data {
      display: flex;
      > div {
        width: 49%;
        height: 300px;
      }
    }
  }
}
</style>